class Solution:
    def mostCompetitive(self, nums: list, k: int) -> list:
        stack = []
        for i in range(len(nums)):
            while stack and stack[-1] > nums[i] and len(nums) - i > k:
                stack.pop()
                k += 1
            if k > 0:
                stack.append(nums[i])
                k -= 1
        return stack
